NewAPITest{ }
setUpClass{ }
tearDownClass{ }
setUp{ }
tearDown{ }
newApiGetDifferentServicesTest{
  Weld weld=new Weld();
  WeldContainer container=weld.initialize();
  TaskServiceEntryPoint taskService=container.instance().select(TaskServiceEntryPointImpl.class).get();
  TaskLifeCycleEventListener taskListener=container.instance().select(TaskLifeCycleEventListener.class).get();
  assertNotNull(taskListener);
  assertTrue(taskListener instanceof JPATaskLifeCycleEventListener);
  TaskEventsService eventsService=taskService.getTaskEventsService();
  TaskIdentityService identityService=taskService.getTaskIdentityService();
  identityService.addUser(new User("salaboy"));
  User salaboy=identityService.getUserById("salaboy");
  assertNotNull(salaboy);
  TaskDefService defService=taskService.getTaskDefService();
  TaskDef taskDef=createSimpleTaskDef("myTaskDef",salaboy);
  defService.deployTaskDef(taskDef);
  TaskDef taskDefById=defService.getTaskDefById("myTaskDef");
  assertNotNull(taskDefById);
  List<TaskDef> allTaskDef=defService.getAllTaskDef("*");
  assertEquals(1,allTaskDef.size());
  Map<String,Object> params=new HashMap<String,Object>();
  long taskId=taskInstanceService.newTask("myTaskDef",params);
  taskInstanceService.start(taskId,"salaboy");
  assertEquals(1,taskEventsById.size());
  Map<String,Object> output=new HashMap<String,Object>();
  output.put("key1","value1");
  output.put("key2",2);
  taskInstanceService.complete(taskId,"salaboy",output);
  assertEquals(1,tasksOwned.size());
  long outputId=queryService.getTaskInstanceById(taskId).getOutputId();
  assertNotNull(outputId);
  assertNotNull(queryService.getContentById(outputId));
  eventsService.removeTaskEventsById(taskId);
  identityService.removeUser("salaboy");
  defService.undeployTaskDef("myTaskDef");
  weld.shutdown();
}
newApiGetMainEntryPointTest{
  Weld weld=new Weld();
  WeldContainer container=weld.initialize();
  TaskServiceEntryPoint taskService=container.instance().select(TaskServiceEntryPointImpl.class).get();
  TaskLifeCycleEventListener taskListener=container.instance().select(TaskLifeCycleEventListener.class).get();
  taskService.addUser(new User("salaboy"));
  User salaboy=taskService.getUserById("salaboy");
  TaskDef taskDef=createSimpleTaskDef("myTaskDef",salaboy);
  taskService.deployTaskDef(taskDef);
  long taskId=taskService.newTask("myTaskDef",params);
  List<TaskSummary> tasksOwned=taskService.getTasksOwned("salaboy");
  taskService.start(taskId,"salaboy");
  List<TaskEvent> taskEventsById=taskService.getTaskEventsById(taskId);
  assertEquals(1,taskEventsById.size());
  taskService.complete(taskId,"salaboy",null);
}
newApiGetMainEntryPointHidingTaskDefTest{
  Weld weld=new Weld();
  TaskServiceEntryPoint taskService=container.instance().select(TaskServiceEntryPointImpl.class).get();
  container.instance().select(TaskLifeCycleEventListener.class).get();
  taskService.addUser(new User("salaboy"));
  TaskDef def=createSimpleTaskDef("myTaskDef",salaboy);
  long taskId=taskService.newTask(def,null);
  TaskInstance taskInstanceById=taskService.getTaskInstanceById(taskId);
  assertNotNull(taskInstanceById);
}
noWeld{
  TaskServiceEntryPoint taskService=new TaskServiceEntryPointImpl();
  taskService.setTaskDefService(new TaskDefServiceImpl());
  taskService.setTaskAdminService(new TaskAdminServiceImpl());
  taskService.setTaskEventsService(new TaskEventsServiceImpl());
  taskService.setTaskIdentityService(new TaskIdentityServiceImpl());
  taskService.setTaskQueryService(new TaskQueryServiceImpl());
  LifeCycleManager lifeCycleManager=new MVELLifeCycleManager(taskService.getTaskDefService(),taskService.getTaskQueryService(),taskService.getTaskIdentityService(),new InternalTaskLifeCycleEventListener());
  taskService.setTaskInstanceService(new TaskInstanceServiceImpl(taskService.getTaskDefService(),lifeCycleManager));
}
hidingWeld{
  TaskServiceEntryPoint taskService=TaskServiceModule.getInstance().getTaskService();
  WeldContainer container=TaskServiceModule.getInstance().getContainer();
  taskService.addUser(new User("salaboy"));
  TaskDef def=createSimpleTaskDef("myTaskDef",salaboy);
  long taskId=taskService.newTask(def,null);
  TaskInstance taskInstanceById=taskService.getTaskInstanceById(taskId);
}
spring{ }
createSimpleTaskDef{
  TaskDef taskDef=new TaskDef(taskDefName);
  PeopleAssignments peopleAssignments=new PeopleAssignments();
  List<OrganizationalEntity> potentialOwners=new ArrayList<OrganizationalEntity>();
  peopleAssignments.setPotentialOwners(potentialOwners);
  taskDef.setPeopleAssignments(peopleAssignments);
  return taskDef;
}
